﻿@model Orion.Models.HomeIndexViewModel

<script src="@Url.Content("~/Scripts/Pagination/jquery.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Pagination/jquery.pagination.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Pagination/jquery.pag.js")" type="text/javascript"></script>
@{
    ViewBag.Title = "IRIS - Innranet - Allar fréttir";
    Layout = "~/Views/Shared/_WorkLayout.cshtml";
}

<section id="main_content">
    <h1>Allar fréttir</h1>

    <div id="Searchresult"></div>
    @{
            var sk = 0;
            for (int m = 0; m < Model.counter; m++)
            {
            <div id="hiddenresult" style="display:none;">
                <div class="result">
     <table>
        <caption></caption>
        <thead>
           <tr>
                <th>Nr.</th>
                <th>Dagsetning</th>
                <th>Titill</th>
                <th>Höf.</th>
                @if (Roles.IsUserInRole("Admin"))
                {
                    <th></th>
                    <th></th>
                }
            </tr>
        </thead>
        <tbody>    
            @foreach (var n in Model.NewsArticle.Skip(sk).Take(Model.displayNewsArticle))
            {
                DateTime temp = n.ContentDate;
                <tr>
                    <td class="id">@n.ID</td>
                    <td class="date">@temp.ToString("dd  MMMM yyyy")</td>
                    <td class="NewsArticleTitle">@Html.ActionLink( n.Title, "GetNewsArticleById/"+@n.ID, "WorkNewsArticle" )</td>
                    <td class="title">@n.Author</td>


                    @if( Roles.IsUserInRole("Admin") )
                    {
                        <td class="action"><b>@Html.ActionLink("Breyta", "EditNewsArticle/" + @n.ID, "WorkNewsArticle")</b></td>
                        if( n.Valid == true )
                        {
                            <td class="action"><b>@Html.ActionLink("Eyða", "DisableNewsArticle/" + @n.ID, "WorkNewsArticle", new { onclick = "return confirm('Ertu viss um að þú viljir eyða fréttinni?')" })</b></td>
                        }
                        else if (n.Valid == false)
                        {
                            <td class="action"><b>@Html.ActionLink("Birta", "EnableNewsArticle/" + @n.ID, "WorkNewsArticle", new { onclick = "return confirm('Ertu viss um að þú viljir birta fréttina?')" })</b></td>
                        }
                    }

                </tr>
            }         
        </tbody>
    </table>
    </div>
            </div>
            sk = sk + Model.displayNewsArticle;
            }
        }    <div id="Pagination"></div>
</section>